package com.cloud.controller;

import com.cloud.domain.LoginUser;
import com.cloud.pojo.UserApplyVolunteer;
import com.cloud.service.ApplyVolunteerService;
import com.cloud.enumeration.ApplyState;
import com.cloud.tools.CommonResult;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 *
 * @author： linJianHong
 * @dateTime： 20:41 2022/4/17
 * @Description: User apply for volunteer control layer
 * @ClassName: ApplyVolunteerController
 */

@RequestMapping("/apply/volunteer")
@RestController
public class ApplyVolunteerController {

    @Resource
    ApplyVolunteerService applyVolunteerService;

    /* 用户提出志愿者申请 */
    @PostMapping(value = "/create")
    @PreAuthorize("hasAnyAuthority('approve:create')")
    public CommonResult applyVolunteerCreate(@RequestBody Map<String,Object> map){
        return applyVolunteerService.create(map);
    }

    /* 用户修改志愿者申请 */
    @PostMapping(value = "/update")
    @PreAuthorize("hasAnyAuthority('approve:update')")
    public CommonResult applyVolunteerUpdate(@RequestBody Map<String,Object> map){
        return applyVolunteerService.userUpdate(map);
    }

    /* 用户撤回志愿者申请 */
    @PostMapping(value = "/delete")
    @PreAuthorize("hasAnyAuthority('approve:delete')")
    public CommonResult applyVolunteerDelete(@RequestBody Map<String,Object> map){
        return applyVolunteerService.delete(map);
    }

    /* 用户查看志愿者申请 */
    @GetMapping(value = "/retrieve")
    @PreAuthorize("hasAnyAuthority('approve:read')")
    public CommonResult applyVolunteerRetrieve(){
        return applyVolunteerService.userRetrieve();
    }
}
